package slu.appli.wodtimer.swing.adapter;

import javax.swing.SwingUtilities;

import slu.appli.wodtimer.ItemTimerListenerInterface;

public abstract class ItemTimerSwingAdapter
implements ItemTimerListenerInterface {

	@Override
	public void elapseDone() {
		this.elapseDoneForSwing();
	}

	private void elapseDoneForSwing() {
		if (SwingUtilities.isEventDispatchThread()) {
			this.elapseDone_Swing();
		}
		else {
			SwingUtilities.invokeLater(new InnerElapseDoneSwingTask());
		}
	}
	
	public abstract void elapseDone_Swing();
	
	private class InnerElapseDoneSwingTask implements Runnable {
		@Override
		public void run() {
			ItemTimerSwingAdapter.this.elapseDone_Swing();
		}
		
	}

}
